package com.cty.share;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;



public class ShareController {

    //springmvc提供的数据共享域(request级别)
    public void data1(Model model) {
        model.addAttribute("nihao");
    }


    public void data1(ModelMap modelMap) {
        modelMap.addAttribute("cty","123456");
    }

    public void data1(Map map) {
        map.put("nihao","123456");
    }

    public void data1(HttpServletRequest request) {
        request.setAttribute("1","2");
    }

    public ModelAndView data1() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("nihao");
        modelAndView.setViewName("cty");
        return modelAndView;
    }
}
